﻿using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using System.Windows;
using System.Windows.Data;
using GA.Server.DatabaseManager;
using GA.Shared.Interfaces;
using GA.Shared.Objects;

namespace GA.Server.Objects
{
    public class DatabaseZone : DatabaseObject
    {
        /// <summary>
        /// Identifies the Name Property.
        /// </summary>
        public static readonly DependencyProperty NameProperty =
            DependencyProperty.Register(
                "Name",
                typeof(string),
                typeof(DatabaseZone),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the Id Property.
        /// </summary>
        public static readonly DependencyProperty IdProperty =
            DependencyProperty.Register(
                "Id",
                typeof(int),
                typeof(DatabaseZone),
                new PropertyMetadata(string.Empty));

        /// <summary>
        /// Identifies the Hexes Property.
        /// </summary>
        public static readonly DependencyProperty HexesProperty =
            DependencyProperty.Register(
                "Hexes",
                typeof(ObservableCollection<Hex>),
                typeof(DatabaseZone),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the OpenTime Property.
        /// </summary>
        public static readonly DependencyProperty OpenTimeProperty =
            DependencyProperty.Register(
                "OpenTime",
                typeof(DateTime),
                typeof(DatabaseZone),
                new PropertyMetadata(null));

        /// <summary>
        /// Identifies the OpenLength Property.
        /// </summary>
        public static readonly DependencyProperty OpenLengthProperty =
            DependencyProperty.Register(
                "OpenLength",
                typeof(int),
                typeof(DatabaseZone),
                new PropertyMetadata(null));

        /// <summary>
        /// Gets or sets the Id.
        /// </summary>
        
        [DatabaseField("Id", IsIdentity = true, IsKey = true)]
        public int Id
        {
            get { return (int)SafeGetValue(IdProperty); }
            set { SafeSetValue(IdProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Name.
        /// </summary>
        
        [DatabaseField("Name", IsQuoted = true, IsKey = true)]
        public string Name
        {
            get { return (string)SafeGetValue(NameProperty); }
            set { SafeSetValue(NameProperty, value); }
        }

        /// <summary>
        /// Gets or sets the Hexes inside the Zone.
        /// </summary>
        
        public ObservableCollection<Hex> Hexes
        {
            get { return (ObservableCollection<Hex>)SafeGetValue(HexesProperty); }
            set { SafeSetValue(HexesProperty, value); }
        }

        /// <summary>
        /// Gets or sets the DateTime which this open.
        /// </summary>
        
        [DatabaseField("OpenTime", IsQuoted = true)]
        public DateTime OpenTime
        {
            get { return (DateTime)SafeGetValue(OpenTimeProperty); }
            set { SafeSetValue(OpenTimeProperty, value); }
        }

        /// <summary>
        /// Gets or sets the length (in seconds) of which this zone is open.
        /// </summary>
        
        [DatabaseField("OpenLength")]
        public int OpenLength
        {
            get { return (int)SafeGetValue(OpenLengthProperty); }
            set { SafeSetValue(OpenLengthProperty, value); }
        }

        public DatabaseZone()
        {
        }

        public DatabaseZone(LinkedDependencyObject baseObject)
            : base(baseObject)
        {
        }

        public DatabaseZone(LinkedDependencyObject baseObject, BindingMode bindingMode)
            : base(baseObject, bindingMode)
        {
        }


        public override void LoadAllPropertyObjects()
        {
            #warning Not Implemented
        }

        public override void LoadPropertyObject(string propertyName)
        {
            #warning Not Implemented
        }
    }
}
